<?php
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
if($_RQ['op']=='list'){
	$params=array('uniacid'=>$_SESSION['uniacid'],'status'=>1);
	if($_RQ['title']){
		$params['title like']='%'.trim($_RQ['title']).'%';
		$return['params']['title']=$_RQ['title'];
	}
	$fields=array('id','title','desc','image','status');
	$orderby=array();
	$_RQ['page'] = $_RQ['page'] ? $_RQ['page'] : 1;
	$pindex = max(1, intval($_RQ['page']));
	if(intval($_RQ['num'])){
		$psize = intval($_RQ['num']);
	}else{
		$psize = 10;
	}
	$total='';
	$list=pdo_getslice('jy_baobiao_notice',$params,array($pindex,$psize),$total,$fields,'',$order);
	$nums=12;
	if($list){
		foreach($list as &$item){
			$item['desc2'] = strip_tags(str_replace('&nbsp;','',$item['content']));
			$item['desc'] = $item['desc'] ? $item['desc'] : cfc('tools')->substr($item['desc2'],0,$nums);
			$item['image'] = $item['image'] ? $item['image'] : '../core/resource/images/nopic.jpg';
			$item['createtime']=date('Y/m/d H:i:s',$item['createtime']);
			$item['url']=custom_url('jy_baobiao/notice/detail/id='.$item['id'],true);
		}
	}
	$sharelink='jy_baobiao/notice/list/fromuser='.$_SESSION['uid'];
	$return['sharedata']=array(
			'title'=>'公告列表 -'.$return['pluginset']['title'],
			'desc'=>$return['pluginset']['title'].'-公告列表',
			'link'=>custom_url($sharelink,true),
			'imgUrl'=>tomedia($return['pluginset']['logo']),
	);
	$return['list']=$list?$list:array();
	set_html('title','公告列表');
	exi($return);
}
if($_RQ['op']=='detail'){
	$article_id=$_RQ['id'];
	$return['item']=pdo_get('jy_baobiao_notice',array('id'=>$article_id,'uniacid'=>$_SESSION['uniacid']));
	if(!$return['item']){
		exi('指定文章不存在！','error','list');
	}
	$return['item']['createtime']=date('20y-m-d',$return['item']['createtime']);
	//去掉多余空样式
	$return['item']['content']=str_replace('style=""','',$return['item']['content']);
	//$return['item']['content'] = str_replace('&nbsp;','',$return['item']['content']);
	$content=strip_tags($return['item']['content']);
	$return['item']['desc'] = $return['item']['desc'] ? $return['item']['desc'] : cfc('tools')->substr($content,0,36);
	$sharelink='jy_baobiao/notice/detail/fromuser='.$_SESSION['uid'].'&id='.$return['item']['id'];
	$return['sharedata']=array(
			'title'=>$return['item']['title'] . '-' . $return['pluginset']['title'],
			'desc'=>$return['item']['desc'],
			'link'=>custom_url($sharelink,true),
			'imgUrl'=>$return['item']['image']?tomedia($return['item']['image']):tomedia($return['pluginset']['logo']),
	);
	set_html('title',$return['item']['title']);
	exi($return);
}